import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';

import fire from '@dfeidao/atom-web/msg/fire';
import error from '@dfeidao/atom-web/msgbox/error';

import get from '@dfeidao/atom-web/local/get';



interface Aa {
	id: string;
	role_no: string;
	role_name: string;
	icon: string;
	role_type_id: string;
}
export default async function a003(fd: IFeidaoAiBrowserComponent, args: Event) {
	//  显示新增弹窗
	const node = args.currentTarget as HTMLInputElement;
	const component_no = node.getAttribute('data-component');
	const event_no = node.getAttribute('data-event') || 'ec-001';
	const name = node.name;

	const productid = get(fd, 'productid');
	const obj = get(fd, 'obj') as Aa;

	if (name === 'zeng') {
		fire(component_no, event_no, productid);
	} else {
		if (!obj) {
			error('请选择角色');
			return;
		}
		if (name === 'quan') {
			fire(component_no, event_no, obj.role_no, obj.role_type_id, productid);
		} else {
			fire(component_no, event_no, obj, obj.id, productid);
		}
	}
}
